package com.tianma315.admin.produce.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.tianma315.admin.common.base.CoreServiceImpl;
import com.tianma315.admin.produce.VO.ScSealVO;
import com.tianma315.admin.produce.domain.ScFeedingDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tianma315.admin.produce.dao.ScSealDao;
import com.tianma315.admin.produce.domain.ScSealDO;
import com.tianma315.admin.produce.service.ScSealService;

import java.util.List;

/**
 * 
 * <pre>
 * 封罐(生产)
 * </pre>
 * <small> 2019-05-30 09:53:18 | Aron</small>
 */
@Service
public class ScSealServiceImpl extends CoreServiceImpl<ScSealDao, ScSealDO> implements ScSealService {

    @Autowired
    private ScSealDao scSealDao;

    @Override
    public Page<ScSealVO> getScSealVOPage(Integer pageNumber, Integer pageSize, ScSealDO scSeal) {
        Page<ScSealVO> page = new Page<>(pageNumber,pageSize);
        page.setRecords(scSealDao.getScSealVOPage(scSeal.getProduceTaskId()));
        return page;
    }

    @Override
    public Boolean addScSealDO(ScSealDO scSeal) {
        scSeal.setState(0);
        return insert(scSeal);
    }

    @Override
    public Boolean deleteScSealDO(Integer id) {
        ScSealDO scSealDO = new ScSealDO();
        scSealDO.setState(1);
        scSealDO.setSealId(id);
        return updateById(scSealDO);
    }

    @Override
    public List<ScSealDO> getScSealDO(Integer produceTaskId) {
        Wrapper<ScSealDO> wrapper = new EntityWrapper<>();
        wrapper.eq("state",0);
        wrapper.eq("produce_task_id",produceTaskId);
        List<ScSealDO> scSealDOList = selectList(wrapper);
        return scSealDOList;
    }
}
